<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Sanpham extends MX_Controller 
{
	protected $lang ;
	function __construct()
	{
        parent::__construct();
		$this->load->model('sanpham_model', 'sanpham') ;
		$this->lang = get_languages() ;
		$this->sanpham->initialise($this->lang) ;
	}
	
	function index($start=0)
	{
        $data['title'] = "Dịch vụ chính" ;
		$config['base_url'] = site().'sanpham/index/';  
		$data['num'] = $this->sanpham->count_all('product'); 
		$config['total_rows'] =  $data['num'];
		$config['per_page'] = 40;
		$config['uri_segment'] = 4;   
		$this->pagination->initialize($config); 
		  
		$data['list'] =   $this->sanpham->get_all('product',$config['per_page'], $start); //trit($data['list']) ;
		$data['pagination']    = $this->pagination->create_links();            
		$data['page'] = 'sanpham/index' ;
		$this->load->view('layout/skin', $data);
	}
	
	function category($cat=0)
	{
		$data['title'] = "Danh mục sản phẩm" ;
		$config['base_url'] = site().'sanpham/category/';  
		$data['num'] = $this->sanpham->count_all('product',$cat); 
		$config['total_rows'] =  $data['num'];
		$config['per_page'] = 12;
		$config['uri_segment'] = 3;   
		$this->pagination->initialize($config); 
		  
		$data['list'] =   $this->sanpham->get_all('product',$config['per_page'],0,$cat);//trit($data['list']);
		$data['pagination']    = $this->pagination->create_links();            
		$data['seg']=$this->uri->segment(1);
		$data['page'] = 'category' ;
		$this->load->view('layout/skin', $data);
	}
	
	// get item of category
	function detail($id)
	{
		$data['title'] = "Chi tiết sản phẩm" ;
		$data['rs']=$this->sanpham->get_id('product','pro_id',$id);
		$data['page'] = 'detail' ;
		$this->load->view('layout/skin', $data);
	}
	
	function listall($cat=0)
	{
		$data['title'] = "Danh mục sản phẩm" ;
		$config['base_url'] = site().'sanpham/category/';  
		$data['num'] = $this->sanpham->count_all('product',$cat); 
		$config['total_rows'] =  $data['num'];
		$config['per_page'] = 12;
		$config['uri_segment'] = 3;   
		$this->pagination->initialize($config); 
		  
		$data['list'] =   $this->sanpham->get_all('product',$config['per_page'],0,$cat);//trit($data['list']);
		$data['pagination']    = $this->pagination->create_links();            
		$data['seg']=$this->uri->segment(1);
		$data['page'] = 'listall' ;
		$this->load->view('layout/skin', $data);
	}
	
}
?>